package com.jinloes.webfit.persistence;

import org.apache.log4j.Logger;

import javax.persistence.*;
import java.util.Date;

@Entity
@Table(name="user")
public class User {
	private static final long serialVersionUID = -722022240875581658L;
	@SuppressWarnings("unused")
	private static final Logger log = Logger.getLogger(User.class);
	
	public User () { super(); }

	public enum Role { BANNED, UNVERIFIED, USER, EDITOR, ADMIN, PICKGAME_ADMIN, ROOT_ADMIN }
    public enum Gender { MALE, FEMALE }
    
    @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name="userId")
    private Long id;

    private String displayName;
    private String firstName;
    private String lastName;
    private String homePhoneNumber;
    
	@Temporal(TemporalType.DATE)
    private Date birthday;

	@Temporal(TemporalType.TIMESTAMP)
    private Date lastPingDate;

	@Temporal(TemporalType.TIMESTAMP)
    private Date lastFrDate;
	
	@Temporal(TemporalType.DATE)
    private Date createdDate;
	
	@Column(name="updatedDate")
	private Date updatedDate;
    private String email;
    private String username;
    private String password;
    private String aboutMe;
    private String lookLike;
    private String website;
    private int communityScore;

    private String address_street;
    private String address_city;
    private String address_state;
    private String address_zipcode;
    private String address_country;
    private String accountStatus;

    @Basic
    @org.hibernate.annotations.Type(type="yes_no")
    private Boolean fromFacebook;
    
    private Long facebookId;
    
    @Enumerated(EnumType.ORDINAL)
    private User.Role role;
    
    @Enumerated(EnumType.ORDINAL)
    private User.Gender gender;

    private String primaryPhotoPath;
    

    /* End of data fields */

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getDisplayName() {
        return displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getHomePhoneNumber() {
        return homePhoneNumber;
    }

    public void setHomePhoneNumber(String homePhoneNumber) {
        this.homePhoneNumber = homePhoneNumber;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public Date getLastPingDate() {
        return lastPingDate;
    }

    public void setLastPingDate(Date lastPingDate) {
        this.lastPingDate = lastPingDate;
    }

    public Date getLastFrDate() {
        return lastFrDate;
    }

    public void setLastFrDate(Date lastFrDate) {
        this.lastFrDate = lastFrDate;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public Date getUpdatedDate() {
        return updatedDate;
    }

    public void setUpdatedDate(Date updatedDate) {
        this.updatedDate = updatedDate;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getAboutMe() {
        return aboutMe;
    }

    public void setAboutMe(String aboutMe) {
        this.aboutMe = aboutMe;
    }

    public String getLookLike() {
        return lookLike;
    }

    public void setLookLike(String lookLike) {
        this.lookLike = lookLike;
    }

    public String getWebsite() {
        return website;
    }

    public void setWebsite(String website) {
        this.website = website;
    }

    public int getCommunityScore() {
        return communityScore;
    }

    public void setCommunityScore(int communityScore) {
        this.communityScore = communityScore;
    }

    public String getAddress_street() {
        return address_street;
    }

    public void setAddress_street(String address_street) {
        this.address_street = address_street;
    }

    public String getAddress_city() {
        return address_city;
    }

    public void setAddress_city(String address_city) {
        this.address_city = address_city;
    }

    public String getAddress_state() {
        return address_state;
    }

    public void setAddress_state(String address_state) {
        this.address_state = address_state;
    }

    public String getAddress_zipcode() {
        return address_zipcode;
    }

    public void setAddress_zipcode(String address_zipcode) {
        this.address_zipcode = address_zipcode;
    }

    public String getAddress_country() {
        return address_country;
    }

    public void setAddress_country(String address_country) {
        this.address_country = address_country;
    }

    public String getAccountStatus() {
        return accountStatus;
    }

    public void setAccountStatus(String accountStatus) {
        this.accountStatus = accountStatus;
    }

    public Boolean getFromFacebook() {
        return fromFacebook;
    }

    public void setFromFacebook(Boolean fromFacebook) {
        this.fromFacebook = fromFacebook;
    }

    public Long getFacebookId() {
        return facebookId;
    }

    public void setFacebookId(Long facebookId) {
        this.facebookId = facebookId;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    public Gender getGender() {
        return gender;
    }

    public void setGender(Gender gender) {
        this.gender = gender;
    }

    public String getPrimaryPhotoPath() {
        return primaryPhotoPath;
    }

    public void setPrimaryPhotoPath(String primaryPhotoPath) {
        this.primaryPhotoPath = primaryPhotoPath;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        User user = (User) o;

        if (communityScore != user.communityScore) return false;
        if (aboutMe != null ? !aboutMe.equals(user.aboutMe) : user.aboutMe != null) return false;
        if (accountStatus != null ? !accountStatus.equals(user.accountStatus) : user.accountStatus != null)
            return false;
        if (address_city != null ? !address_city.equals(user.address_city) : user.address_city != null) return false;
        if (address_country != null ? !address_country.equals(user.address_country) : user.address_country != null)
            return false;
        if (address_state != null ? !address_state.equals(user.address_state) : user.address_state != null)
            return false;
        if (address_street != null ? !address_street.equals(user.address_street) : user.address_street != null)
            return false;
        if (address_zipcode != null ? !address_zipcode.equals(user.address_zipcode) : user.address_zipcode != null)
            return false;
        if (birthday != null ? !birthday.equals(user.birthday) : user.birthday != null) return false;
        if (createdDate != null ? !createdDate.equals(user.createdDate) : user.createdDate != null) return false;
        if (displayName != null ? !displayName.equals(user.displayName) : user.displayName != null) return false;
        if (email != null ? !email.equals(user.email) : user.email != null) return false;
        if (facebookId != null ? !facebookId.equals(user.facebookId) : user.facebookId != null) return false;
        if (firstName != null ? !firstName.equals(user.firstName) : user.firstName != null) return false;
        if (fromFacebook != null ? !fromFacebook.equals(user.fromFacebook) : user.fromFacebook != null) return false;
        if (gender != user.gender) return false;
        if (homePhoneNumber != null ? !homePhoneNumber.equals(user.homePhoneNumber) : user.homePhoneNumber != null)
            return false;
        if (id != null ? !id.equals(user.id) : user.id != null) return false;
        if (lastFrDate != null ? !lastFrDate.equals(user.lastFrDate) : user.lastFrDate != null) return false;
        if (lastName != null ? !lastName.equals(user.lastName) : user.lastName != null) return false;
        if (lastPingDate != null ? !lastPingDate.equals(user.lastPingDate) : user.lastPingDate != null) return false;
        if (lookLike != null ? !lookLike.equals(user.lookLike) : user.lookLike != null) return false;
        if (password != null ? !password.equals(user.password) : user.password != null) return false;
        if (primaryPhotoPath != null ? !primaryPhotoPath.equals(user.primaryPhotoPath) : user.primaryPhotoPath != null)
            return false;
        if (role != user.role) return false;
        if (updatedDate != null ? !updatedDate.equals(user.updatedDate) : user.updatedDate != null) return false;
        if (username != null ? !username.equals(user.username) : user.username != null) return false;
        if (website != null ? !website.equals(user.website) : user.website != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (displayName != null ? displayName.hashCode() : 0);
        result = 31 * result + (firstName != null ? firstName.hashCode() : 0);
        result = 31 * result + (lastName != null ? lastName.hashCode() : 0);
        result = 31 * result + (homePhoneNumber != null ? homePhoneNumber.hashCode() : 0);
        result = 31 * result + (birthday != null ? birthday.hashCode() : 0);
        result = 31 * result + (lastPingDate != null ? lastPingDate.hashCode() : 0);
        result = 31 * result + (lastFrDate != null ? lastFrDate.hashCode() : 0);
        result = 31 * result + (createdDate != null ? createdDate.hashCode() : 0);
        result = 31 * result + (updatedDate != null ? updatedDate.hashCode() : 0);
        result = 31 * result + (email != null ? email.hashCode() : 0);
        result = 31 * result + (username != null ? username.hashCode() : 0);
        result = 31 * result + (password != null ? password.hashCode() : 0);
        result = 31 * result + (aboutMe != null ? aboutMe.hashCode() : 0);
        result = 31 * result + (lookLike != null ? lookLike.hashCode() : 0);
        result = 31 * result + (website != null ? website.hashCode() : 0);
        result = 31 * result + communityScore;
        result = 31 * result + (address_street != null ? address_street.hashCode() : 0);
        result = 31 * result + (address_city != null ? address_city.hashCode() : 0);
        result = 31 * result + (address_state != null ? address_state.hashCode() : 0);
        result = 31 * result + (address_zipcode != null ? address_zipcode.hashCode() : 0);
        result = 31 * result + (address_country != null ? address_country.hashCode() : 0);
        result = 31 * result + (accountStatus != null ? accountStatus.hashCode() : 0);
        result = 31 * result + (fromFacebook != null ? fromFacebook.hashCode() : 0);
        result = 31 * result + (facebookId != null ? facebookId.hashCode() : 0);
        result = 31 * result + (role != null ? role.hashCode() : 0);
        result = 31 * result + (gender != null ? gender.hashCode() : 0);
        result = 31 * result + (primaryPhotoPath != null ? primaryPhotoPath.hashCode() : 0);
        return result;
    }
}
